package cn.hackcloud.concurrency.bus;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class TestEventBus {
    public static void main(String[] args) {
        syncEventBus();
    }

    private static void syncEventBus() {
        Bus bus = new EventBus("TestBus");
        bus.register(new SimpleObject());
        bus.register(new SimpleObject());
        bus.post("Hello");
        System.out.println("-----------");
        bus.post("Hello2", "test");
    }

    private static void asyncEventBus() {
        Bus bus = new AsyncEventBus("TestBus", (ThreadPoolExecutor) Executors.newFixedThreadPool(10));
        bus.register(new SimpleObject());
        bus.register(new SimpleObject());
        bus.post("Hello");
        System.out.println("-----------");
        bus.post("Hello2", "test");
    }
}
